<script lang="ts" setup>
import useOnlineHooks from '@/hooks/useOnline'

const { onListenNetwork, offListenNetwork, isOnlineRef, isWeakLineRef } = useOnlineHooks()
onListenNetwork()
onBeforeUnmount(() => {
  offListenNetwork()
})
</script>
<template>
  <view class="default-layout">
    <slot v-if="isOnlineRef && !isWeakLineRef" />
    <view v-else-if="!isOnlineRef">网络异常</view>
    <view v-else>弱网</view>
  </view>
</template>

<style lang="scss">
.default-layout {
  overflow: auto;
}
</style>
